package com.example.mybutton;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import java.lang.reflect.Field;

import androidx.annotation.Nullable;

public class NotificationActivity  extends Activity {
    private SeekBar sb_normal;
    private TextView txt_cur;
    private Context mContext;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Log.e("leo", "onCreate: 进入NotificationActivity" );
        mContext = NotificationActivity.this;
        bindViews();

    }
    private void bindViews() {
        sb_normal = (SeekBar) findViewById(R.id.sb_normal);
        txt_cur = (TextView) findViewById(R.id.txt_cur);
        //进度条
       // sb_normal.setProgressDrawable(SkinManager.getInstance().getSkinResource().getDrawable(
             //   SkinManager.getInstance().getId("sb_bar", "drawable")));
        sb_normal.setPadding(20, 20, 20, 20);
      //  setSeekBarMaxHeight(sb_normal);
        //小球
      //  sb_normal.setThumb(SkinManager.getInstance().getSkinResource()
      //          .getDrawable(SkinManager.getInstance().getId("sb_thumb", "drawable")));
        sb_normal.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                txt_cur.setText("当前进度值:" + progress + "  / 100 ");
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                Toast.makeText(mContext, "触碰SeekBar", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                Toast.makeText(mContext, "放开SeekBar", Toast.LENGTH_SHORT).show();
            }
        });

    }
    private void setSeekBarMaxHeight(SeekBar seekbar) {
        try {
            Class<?> superclass = seekbar.getClass().getSuperclass().getSuperclass();
            Field mMaxHeight = superclass.getDeclaredField("mMaxHeight");
            mMaxHeight.setAccessible(true);
            mMaxHeight.set(seekbar, 20);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
